Hello Forums, i want to get some information from a skip list , i get error in line 27 , can anyone help please ?
pragma runLim, 0
Module m = current
Object o
filtering off
Skip objList = create()
for o in m do {
{
Regexp Reference = regexp2 "\\[[I][t][_]+([0-9]+)\\]"
string theText= (o."Object Text" "") (o."Object Heading" "")
string ReferenceNumber
if (Reference theText) {
ReferenceNumber = theText[match 1]
int iReferenceNumber = intOf realOf ReferenceNumber
put (objList,iReferenceNumber,o)
}
}
}
string absNum
string s
for o in m do {
s = o."status"
if ( s != " "){
absNum = o."Absolute Number"
int absNum1 = intOf realOf absNum
for iReferencNumber in objList do {
if ( absNum1 = iReferenceNumber )
{ print absNum1 "status is ok" "\n"}
}
}
}
Best regards, Control17 - Fri Aug 18 02:45:01 EDT 2017 | ||||||||||||||||||||
Re: loop in skip list You need to use the comparsion operator: if ( absNum1 == iReferenceNumber ) // do not use if (a = b) Regards, Mathias | ||||||||||||||||||||
Re: loop in skip list Mathias Mamsch - Fri Aug 18 05:25:11 EDT 2017 You need to use the comparsion operator: if ( absNum1 == iReferenceNumber ) // do not use if (a = b) Regards, Mathias thanks for reply , i do it and i get no error but my code find not the absNum1 ? my code should give me It_2 ?
can anyone help? Best regards ,
| ||||||||||||||||||||
Re: loop in skip list Control17 - Fri Aug 18 08:03:18 EDT 2017 thanks for reply , i do it and i get no error but my code find not the absNum1 ? my code should give me It_2 ?
can anyone help? Best regards ,
It is not clear to me, what "Absno." is? Is it the object identifier (the concatenation of the content of the module attribute "Prefix" and the object's "Absolute Number")? Or is it a different attribute that is manually filled by your users? If the latter is the case, you should be aware of when you use the "Absno.", when you use the "reference" and when you use the "Absolute Number". It might well be that the first object shown in your table has the "Absolute Number" 1 and the "Absno." IT_2. Then, in your first loop you create a skip list where the key of your skip list is the number of the referenced object (well, you hope that the referencing object contains only one reference) and the value is the referencing object. So, you might have a problem when two different objects contain a reference to the same object or when one object references two other objects. You might want to rethink your data model. In your second loop you have a loop over the skip list, but "for xx in skip" will not give the key to xx but the value(!) of the skip list's entry, so you should have something like "for oReferencing in objList". You can get the referenced key using the "key" function (see DXL manual). Finally, you have a typo: you say "for iReferencNumber in" but you use the variable iReferenc*e*Number. Search the forum on AutoDeclare on how to detect such errors. | ||||||||||||||||||||
Re: loop in skip list and there are some more issues. - As "Absolute Number" is of type integer, you can declare your variable absNum of type int. Thus you do not need absNum1. - what exactly do you want to print in line 28? The absolute Number of the object that is OK? Then you don't need most of your code. The absolute Number of your referencing object? Then you need to get it from the skip list - As you already have the key to your skiplist in absNum, you don't need the inner loop of your second loop. You can directly access the referencing object using the "find" command, see the section about Skip Lists in DXL Reference manual
| ||||||||||||||||||||
Re: loop in skip list Mike.Scharnow - Fri Aug 18 11:11:14 EDT 2017 and there are some more issues. - As "Absolute Number" is of type integer, you can declare your variable absNum of type int. Thus you do not need absNum1. - what exactly do you want to print in line 28? The absolute Number of the object that is OK? Then you don't need most of your code. The absolute Number of your referencing object? Then you need to get it from the skip list - As you already have the key to your skiplist in absNum, you don't need the inner loop of your second loop. You can directly access the referencing object using the "find" command, see the section about Skip Lists in DXL Reference manual
Hello, i really appreciate your help, yes in line 28 i want to print absolute Number of the object that is ok . how can i use "find" command in skiplist , is my code right ?
pragma runLim, 0
Module m = current
Object o
filtering off
Skip objList = create()
for o in m do {
{
Regexp Reference = regexp2 "\\[[I][t][_]+([0-9]+)\\]"
string theText= (o."Object Text" "") (o."Object Heading" "")
string ReferenceNumber
if (Reference theText) {
ReferenceNumber = theText[match 1]
int iReferenceNumber = intOf realOf ReferenceNumber
put (objList,iReferenceNumber,o)
}//if
}//Regexp
}//for
int absNum
string s
for o in m do {
s = o."status"
if ( s != " "){
absNum = o."Absolute Number"
if find (objlist,absNum,o){
print absNum "\n"
}//if
}//if
}//for
thank u for your help ,
Neven
| ||||||||||||||||||||
Re: loop in skip list Control17 - Mon Aug 21 05:26:07 EDT 2017 Hello, i really appreciate your help, yes in line 28 i want to print absolute Number of the object that is ok . how can i use "find" command in skiplist , is my code right ?
pragma runLim, 0
Module m = current
Object o
filtering off
Skip objList = create()
for o in m do {
{
Regexp Reference = regexp2 "\\[[I][t][_]+([0-9]+)\\]"
string theText= (o."Object Text" "") (o."Object Heading" "")
string ReferenceNumber
if (Reference theText) {
ReferenceNumber = theText[match 1]
int iReferenceNumber = intOf realOf ReferenceNumber
put (objList,iReferenceNumber,o)
}//if
}//Regexp
}//for
int absNum
string s
for o in m do {
s = o."status"
if ( s != " "){
absNum = o."Absolute Number"
if find (objlist,absNum,o){
print absNum "\n"
}//if
}//if
}//for
thank u for your help ,
Neven
Hi Neven, perhaps it is time to step back a bit and tell us your overall goal. What your code currently does, is
What I *think* you may want to achieve is
Or perhaps
Depending on your need the script might look different. Some comments on your code:
Regards, | ||||||||||||||||||||
Re: loop in skip list Mike.Scharnow - Mon Aug 21 06:58:48 EDT 2017 Hi Neven, perhaps it is time to step back a bit and tell us your overall goal. What your code currently does, is
What I *think* you may want to achieve is
Or perhaps
Depending on your need the script might look different. Some comments on your code:
Regards, Hi Mike, thank u for ur reply, My code should do following: At first search in object text and object heading the reference "[It_ absolute no. ]" and take this absolute no. and find out whether the status ok is, in this case print the absolute no. (i mean hier 2 and 3) .
Regards, Neven
| ||||||||||||||||||||
Re: loop in skip list Control17 - Mon Aug 21 07:41:39 EDT 2017 Hi Mike, thank u for ur reply, My code should do following: At first search in object text and object heading the reference "[It_ absolute no. ]" and take this absolute no. and find out whether the status ok is, in this case print the absolute no. (i mean hier 2 and 3) .
Regards, Neven
So, when you run your script on this module, the result should be 2 3 because 2 and 3 are referenced and ok and 4 is referenced but not ok? In this case you should already have what you need if you take your code from today and make the changes:
| ||||||||||||||||||||
Re: loop in skip list Mike.Scharnow - Mon Aug 21 07:58:33 EDT 2017 So, when you run your script on this module, the result should be 2 3 because 2 and 3 are referenced and ok and 4 is referenced but not ok? In this case you should already have what you need if you take your code from today and make the changes:
thank you. Regards, Neven | ||||||||||||||||||||